import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_study_app/app/router/router_param.dart';
import 'package:flutter_study_app/app/router/routers.dart';
import 'package:flutter_study_app/module/view/storage_special_region_item_view.dart';
import 'package:flutter_study_app/widget/my_app_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class StorageSpecialRegionPage extends StatefulWidget {
  int type;
  StorageSpecialRegionPage({this.type = 0});

  @override
  State<StatefulWidget> createState() => _StorageSpecialRegionPageState();
}

class _StorageSpecialRegionPageState extends State<StorageSpecialRegionPage> {
  String _name = "";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: MyAppBar(
          title: widget.type == 0 ? '额度支用专区' : '额度续存专区',
          showDivider: true,
          rightMenu: Row(
            children: [
              InkWell(
                  onTap: () {
                    EasyLoading.showToast("点击排序");
                  },
                  child: Container(
                    padding: EdgeInsets.only(left: 20.w, right: 5.w),
                    child: Image.asset(
                      'assets/images/ic_sort.png',
                      width: 20.w,
                      height: 20.w,
                    ),
                  )),
              InkWell(
                  onTap: () {
                    //EasyLoading.showToast("点击搜索");
                    RouterParam param = RouterParam();
                    param.putString("name", _name);
                    Routers.navigateToResult(
                        context, Routers.storageSpecialRegionSearchPage,
                        (data) {
                      if (data != null && data is Map) {
                        _name = data['name'] ?? '';
                      }
                    }, parameters: param);
                  },
                  child: Container(
                    padding: EdgeInsets.only(left: 5.w, right: 15.w),
                    child: Image.asset(
                      'assets/images/ic_search.png',
                      width: 20.w,
                      height: 20.w,
                    ),
                  )),
            ],
          ),
        ),
        body: ListView.builder(
          itemCount: 10,
          itemBuilder: (context, index) {
            return Container(
              margin: EdgeInsets.only(
                  left: 12.w, right: 12.w, top: 6.w, bottom: 6.w),
              child: StorageSpecialRegionItemView(
                type: widget.type,
              ),
            );
          },
        ));
  }
}
